#pragma once 
#include "Dictionary.h"
#include "TcpConnection.h"
#include "CandidateResult.h"
#include <queue>
using std::priority_queue;
using TcpConnectionPtr = shared_ptr<TcpConnection>;

class KeyRecommander{
public:
    KeyRecommander(const string &_sought, TcpConnectionPtr _con);
    // 将候选词加入队列
    void doQuery();

    // 输出结果
    void response();

private:
    void searchCn();
    void searchEn();
    bool is_eng(const string& str);
private:
    Dictionary *_pDictionary;
    vector<pair<string, size_t>>& _en_dict;
    map<string, set<int>>& _en_index;
    vector<pair<string, size_t>>& _cn_dict;
    map<string, set<int>>& _cn_index;
    string _sought;
    TcpConnectionPtr _con;
    priority_queue<CandidateResult> _prique;
};